package com.ala4.oxcafe.controller;

import com.ala4.oxcafe.boot.annotation.Permission;
import com.ala4.oxcafe.boot.page.PageDomain;
import com.ala4.oxcafe.boot.page.PageResult;
import com.ala4.oxcafe.domain.R;
import com.ala4.oxcafe.entity.RegionInfo;
import com.ala4.oxcafe.repository.RegionInfoRepository;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 地址管理
 *
 * @author PING
 * @version 1.0.0
 * @date 2025/8/13 12:44
 */
@RestController
@RequestMapping("/region-info")
@AllArgsConstructor
@Tag(name = "地址管理", description = "用于管理地址信息")
public class RegionInfoController {

    private final RegionInfoRepository regionInfoRepository;

    @Operation(summary = "分页查询地址")
    @GetMapping("/page")
    public R<PageResult<RegionInfo>> page(PageDomain pageDomain, RegionInfo regionInfo) {
        return R.ok(PageResult.iPage(regionInfoRepository.selectRegionInfoPage(pageDomain, regionInfo)));
    }

    @Operation(summary = "列表查询地址")
    @GetMapping("/list")
    @Permission(permissionPublic = true)
    public R<List<RegionInfo>> list(RegionInfo regionInfo) {
        return R.ok(regionInfoRepository.selectRegionInfoList(regionInfo));
    }

}
